#!/usr/bin/env bash

tags_dir=~/.tags

if [ ! -d $tags_dir ]; then
    mkdir -p $tags_dir
fi

#--verbose=yes \
    cmd="ctags -R  --languages=c++,c \
    --langmap=c++:+.inl \
    --langmap=c++:+.h \
    -h +.inl \
    --sort=yes \
    --c++-kinds=+p --fields=+afiKlmnsSzt --extras=+qf \
    --if0=no --links=yes \
    --exclude=bak --exclude=build --exclude=build_cocoa_debug --exclude={vbuild,node_modules,googletest,.git,tmp.*.bak,.svn,CI,CD} \
    --exclude=hdocs --exclude=tarball "

if [ "$1"x == "file"x ] ; then
    cmd="$cmd -f $tags_dir/ ~/git/"
    echo $cmd
elif [ "$1"x == "gateway"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags  ~/git/gateway/src"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "rest"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags  ~/git/gateway/dependence/cpprestsdk"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "boost67"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/tarball/boost_1_67_0"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "boost71"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/tarball/boost_1_71_0"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "boost"x ] ; then
    cmd="$cmd -f $tags_dir/boost.tags ~/git/tarball/boost_1_61_0"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "olc"x ] ; then
    cmd="$cmd -f $tags_dir/olc.tags ~/git/olc1"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "qmdb"x ] ; then
    cmd="$cmd -f $tags_dir/qmdb.tags ~/git/qmdb/src"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "scf"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/scf-core/"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "fip"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/fip/src"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "wf"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/wf3000/src"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "ceph"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/chfs/ceph/15/ceph-15.2.14/src"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "dds"x ] ; then
    cmd="$cmd -f $tags_dir/$1.tags ~/git/xilinx/src/opensplice-master"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "eos.1.8.9"x ] ; then
    cmd="$cmd --exclude=eos.v1.5  -f $tags_dir/$1.tags ~/git/eos/eosio/eos.v1.8.9"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "eos"x ] ; then
    cmd="$cmd  -f $tags_dir/$1.tags ~/git/eos/eosio/eos"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "eosvm"x ] ; then
    cmd="$cmd --exclude=eos.v1.5  -f $tags_dir/$1.tags ~/git/eos/eosio/eos-vm"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "eosvm2"x ] ; then
    cmd="$cmd --exclude=eos.v1.5  -f $tags_dir/$1.tags ~/git/eos/eosio/eos-vm.eosio"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "openssl"x ] ; then
    cmd="$cmd --exclude=eos.v1.5  -f $tags_dir/$1.tags ~/run/openssl"
    echo $cmd
    echo $cmd | bash
elif [ "$1"x == "dos"x ] ; then
    cmd="$cmd --exclude=eos.v1.5  -f $tags_dir/$1.tags ~/git/dos"
    echo $cmd
    echo $cmd | bash


else
    echo $cmd
    #echo "ctags -R  --languages=c++ --langmap=c++:+.inl -h +.inl --c++-kinds=+p --fields=+aiKSz --extra=+qf --exclude=.svn --exclude=.git --exclude=*.bak --exclude=tmp --exclude=bak --exclude=build --exclude=build_cocoa_debug --exclude=r90  --exclude=hdocs --exclude=tarball"

fi
#echo "ctags -R  --languages=c++ --langmap=c++:+.inl -h +.inl --c++-kinds=+p --fields=+aiKSz --extra=+qf --exclude=.svn--exclude=.git --exclude=*.bak --exclude=tmp --exclude=tarball"
